package com.yaolifei.flower.core;

import java.util.Date;

public enum ModelColumnType {

	INT("整型", 1, "int", int.class), 
	VARCHAR("字符型", 2, "varchar", String.class), 
	DATETIME("日期型", 3, "datetime", Date.class);

	private ModelColumnType(String name, int value, String sqlType, Class<? extends Object> javaClass) {
		this.name = name;
		this.value = value;
		this.sqlType = sqlType;
		this.javaClass = javaClass;
	}

	private int value;
	private String sqlType;
	private Class<? extends Object> javaClass;
	private String name;
	
	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
	}

	public String getSqlType() {
		return sqlType;
	}

	public void setSqlType(String sqlType) {
		this.sqlType = sqlType;
	}

	public Class<? extends Object> getJavaClass() {
		return javaClass;
	}

	public void setJavaClass(Class<? extends Object> javaClass) {
		this.javaClass = javaClass;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static ModelColumnType valueOf(int value) {
		for (ModelColumnType type : values()) {
			if (type.getValue() == value) {
				return type;
			}
		}
		return null;
	}
	
	@Override
	public String toString() {
		return this.value + ", " + this.sqlType + ", " + this.javaClass + ", " + this.name;
	}

}
